Xbasic

FILENAME_TO_ALIAS Function

Syntax

Alias_Filename as C = filename_to_alias(C filename )

Arguments

filename

A fully qualified filename with path.

Description

Converts a filename to an aliased filename

Discussion

FILENAME_TO_ALIAS() returns a character string after converting a filename to an aliased filename. The value of the FILENAME_FROM_ALIAS()and FILENAME_TO_ALIAS() functions is that they make it easier to develop an application that is less location dependent. You can define file aliases on the "Alias" tab in the View Settings dialog. For example, the alias [image_folder] can refer to c:\images\ on one user's machine, and d:\data\images on another machine. Aliases are particularly useful if you use the new field type "Image File Reference" which stores an image filename in the field rather than the field itself. When you transport the database and the folder which contains the images to another machine that has different drive mappings, all that you have to do on the new machine is ensure that an appropriate entry exists in the alias table. (The aliases are actually stored in the a_aliases.aliases text file in the Alpha Anywhere program folder). The alias reference can be an explicit drive/path, or it can be an expression that evaluates to a drive/path. For example, the alias [exepath] could be set to " = a5.get_exe_path()". To specify an expression, prefix the expression with " = ". To define an alias in Alpha Anywhere:

1. Click View > Settings.
2. Select System > Aliases.
3. Enter the name of the new alias in the Alias field in the format " [name\] ".
4. Enter the path of the folder in the Path field.
5. Click OK.

In the following example, [documents] is defined as " c:\documents\ ".

Example

dim cs as C
cs = filename_to_alias("c:\documents\upgrade.txt")
? cs
= "[Documents]upgrade.txt"
? filename_to_alias("C:\Program Files\A5V7\Samples\AlphaSports\AlphaSports.alb")
= "[exe_folder]\Samples\AlphaSports\AlphaSports.alb"

See Also